$(function () {
   obj.init();
});
var obj = new function () {
    'use strict';
    return {
        form:null,
        id:null,
        init:function () {
            this.id = xhTool.getQuery('id');
            this.form = new xhForm($('#xh_form'));
            this.form.parse();
            $('#template').select2();
            this.listener();
        },
        listener:function () {
            var $this = this;
            //模板选中
            $('#template').change(function () {
                var val = $('[name=content]').val();
                $('[name=content]').val(val+$(this).val());
            });

            //确认
            $('#bt_modal_confirm', parent.document).click(function () {
                $this.funObj().submitForm();
            });

        },
        funObj:function () {
            var $this = this;
            return {
                submitForm:function () {
                    $this.form.submit('feedback/replyFeedBack', {id:$this.id},function (res) {
                        window.top.xhTop.showSuccess(res.msg);
                        if (xhTool.getQuery('needReload') == 'true') {
                            window.top.xhTop.getActiveFrame().obj.dataGrid.reload();
                        }
                        window.top.xhTop.getActiveFrame().obj.frame[0].contentWindow.location.reload();
                        window.top.xhTop.closeModal();
                    })
                }
            }
        }
    }
};